Skip to content

docs: fix ragged list example in model intro to ensure rectangular shape#1212

Open
anmol52490 wants to merge 1 commit intohuggingface:mainfrom
anmol52490:patch-1
Open

docs: fix ragged list example in model intro to ensure rectangular shape#1212
anmol52490 wants to merge 1 commit intohuggingface:mainfrom
anmol52490:patch-1

Conversation

@anmol52490
Copy link
Copy Markdown

In the "Models" section of the documentation, the example regarding tensor conversion contained a logical error. It presented a list of two sequences with unequal lengths (16 and 8 tokens) while stating the structure was "already of rectangular shape."

This would cause a ValueError when passed to torch.tensor().

This PR:

  • Updates the encoded_sequences example to include padding zeros for the second sequence.
  • Clarifies that the tokenization step assumes padding=True to achieve this shape.
  • Ensures the code snippets are functionally accurate for users copying them into a PyTorch environment.

In the "Models" section of the documentation, the example regarding tensor conversion 
contained a logical error. It presented a list of two sequences with unequal 
lengths (16 and 8 tokens) while stating the structure was "already of rectangular 
shape." 

This would cause a ValueError when passed to torch.tensor().

This PR:
- Updates the encoded_sequences example to include padding zeros for the second sequence.
- Clarifies that the tokenization step assumes `padding=True` to achieve this shape.
- Ensures the code snippets are functionally accurate for users copying them into 
  a PyTorch environment.
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@anmol52490
Copy link
Copy Markdown
Author

Hello, respective maintainer @julien-c or @thliang01. Please, do review and confirm this PR if the fix looks correct.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants